<?php

// Start sessions, we'll use this to store a hash of md5 keyed generated prices.
session_start();

// Include cart classes
include_once 'library/Brandon/Post.php';
include_once 'library/Brandon/Response.php';
include_once 'library/Brandon/LineItem.php';

// Get itemName from POST, get as string
$itemName = Brandon\Post::getString('itemName');

// Get itemQuantity from POST, get as integer
$itemQuantity = Brandon\Post::getInteger('itemQuantity');

// Create new line item object, lookup item by name and get price
$lineItem = new Brandon\LineItem();
$lineItem->setQuantity($itemQuantity)
	->generatePrice($itemName);

// Create new response object, set the status and data array, send back response to client
$response = new Brandon\Response();
$response->status('ok')
	->data(array(
		'price' => $lineItem->getPrice(),
		'quantity' => $lineItem->getQuantity(),
		'total' => $lineItem->getTotal(),
	))
	->send();